package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.app.util.UserContext;
import cn.wolfcode.trip.base.domain.Commodity;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ICommodityService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("commodities")
public class CommodityController {
    @Autowired
    private ICommodityService commodityService;

    @GetMapping
    public PageInfo<?> list(QueryObject qo){
        return commodityService.query(qo);
    }

    @GetMapping("/{userId}/getForms")
    public JsonResult getForms(@PathVariable Long userId){
        List<Commodity> list = commodityService.getForms(userId);
        return new JsonResult().setResult(list);
    }

}
